package org.sun.web.others;

import java.io.File;
import java.io.IOException;
import java.util.HashMap;
import java.util.Map;

import org.sun.web.util.DataUtil;
import org.sun.web.util.FileUtil;

public class FileIOControl {

	public static void writeFile(String name,String option){
		//String name="test.js";
		String pkg=FileIOControl.class.getPackage().getName();
		pkg=pkg.replace(".", "/");
		String path=FileIOControl.class.getResource("").getPath();
		System.out.println(path);
		File f=new File(path+name);
		if(!f.exists())
			try {
				f.createNewFile();
			} catch (IOException e) {
				e.printStackTrace();
			}
		System.out.println(f.getPath());
	}
	public static void main(String[] args) {
		String path=FileIOControl.class.getResource("").getPath();
		File file=new File(path+"tst.js");
		Map<Object,Object> o=DataUtil.toMap("title","blue","name","dashboard");
		FileUtil.writeFile(file, DataUtil.toJson(o));
		String json=FileUtil.readFile(file);
		System.out.println(json);
	}
}
